Skip to content

bpo-40294: Fix use-after-free in _asynciomodule.c when module is loaded/unloaded multiple times#19542

Merged
vstinner merged 1 commit intopython:masterfrom
jquesnelle:bpo40294
Apr 17, 2020
Merged

bpo-40294: Fix use-after-free in _asynciomodule.c when module is loaded/unloaded multiple times#19542
vstinner merged 1 commit intopython:masterfrom
jquesnelle:bpo40294

Conversation

@jquesnelle
Copy link
Contributor

@jquesnelle jquesnelle commented Apr 15, 2020

GH-16598 added the static variable module_initialized to _asynciomodule.c to guard against multiple initializations and instead re-use the resources from the first initialization. However, the variable isn't cleared in module_free(). If the module is again initialized after module_free is called, the program will crash. In particular, Py_INCREF(all_tasks); in PyInit__asyncio() will access invalid memory.

The fix seems straightforward: simply clear the flag in module_free(). This seems symmetric with it being set in module_init().

https://bugs.python.org/issue40294

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants